/**
 * Created by xinhuang on 15/3/9.
 */
(function () {
  'use strict';
  angular.module('sasApp.directives', [
    'directives.timeValidate',
    'directives.form',
    'directives.customActivity',
    'directive.switchingButton'
  ])
    .directive('repeatFinish', repeatFinish)
    .directive('coreLoading', coreLoading)
    .directive('ckDrag', ckDrag);

  function coreLoading() {
    return {
      restrict: 'E',
      replace: true,
      template: '<div class="my-loading"><md-progress-circular class="md-hue-2" md-mode="indeterminate"></md-progress-circular></div>'
    };
  }

  function repeatFinish() {
    return {
      restrict: 'A',
      link: function (scope, element, attrs) {
        if (scope.$last) {
          setTimeout(function () {
            scope.$emit('onRepeatLast', element, attrs);
          }, 1);
        }
      }
    };
  }

  function ckDrag() {
    return {
      restrict: 'AE',
      link: function (scope, element) {
        $(element).ckDrag();
      }
    }
  }
})();